package com.newbee.controller;

import com.newbee.model.common.CommonResponse;
import com.newbee.model.demo.DemoRequest;
import com.newbee.model.demo.DemoResponse;
import com.newbee.service.DemoServiceA;
import com.newbee.service.DemoServiceC;
import com.newbee.service.DemoServiceD;
import com.newbee.service.DemoServiceE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/demo")
@RestController
public class DemoController {

    @Autowired
    private DemoServiceA demoServiceA;

    @Autowired
    private DemoServiceC demoServiceC;

    @Autowired
    private DemoServiceD demoServiceD;

    @Autowired
    private DemoServiceE demoServiceE;

    @GetMapping("/test1")
    public CommonResponse<DemoResponse> demoTest1(DemoRequest req) {
        int x = demoServiceA.funcA(req);
        DemoResponse demoResponse = new DemoResponse();
        demoResponse.setX(x);
        return CommonResponse.success(demoResponse);
    }

    @GetMapping("/test2")
    public CommonResponse<DemoResponse> demoTest2(DemoRequest req) {
        int e = demoServiceE.funcE(req.getX());
        DemoResponse demoResponse = new DemoResponse();
        demoResponse.setX(e);
        return CommonResponse.success(demoResponse);
    }
}
